var t = getApp(), a = require("../../api.js");

Page({
    data: {
        dates: "本月",
        payment: "",
        month: "",
        moneyList: "",
        page: 1,
        pageSize: 10,
        hasMoreData: !0,
        According: !1,
        minmoney: "",
        maxmoney: ""
    },
    onLoad: function(t) {
        1 == t.payment && this.setData({
            isShowCenter: !0
        });
        var a = new Date(), e = a.getFullYear() + "-" + ("0" + (a.getMonth() + 1)).slice(-2);
        this.setData({
            payment: t.payment,
            month: e
        });
    },
    bindDateChange: function(t) {
        var a = new Date(), e = a.getFullYear() + "-" + ("0" + (a.getMonth() + 1)).slice(-2);
        t.detail.value == e ? this.setData({
            dates: "本月",
            month: t.detail.value
        }) : this.setData({
            dates: t.detail.value,
            month: t.detail.value
        }), this.data.page = 1, this.getList();
    },
    getList: function() {
        var e = this;
        t.request({
            url: a.distribution.commission_detail,
            method: "post",
            data: {
                payment: e.data.payment,
                month: e.data.month,
                page: e.data.page
            },
            success: function(t) {
                var a = e.data.moneyList;
                if (1 == t.code) {
                    wx.hideLoading(), e.setData({
                        minmoney: t.data.commission,
                        maxmoney: t.data.total_commission
                    }), 1 == e.data.page && (a = []);
                    var n = t.data.data;
                    0 == n.length ? e.setData({
                        moneyList: n,
                        hasMoreData: !1,
                        According: !0
                    }) : n.length < e.data.pageSize ? e.setData({
                        moneyList: a.concat(n),
                        hasMoreData: !1,
                        According: !1
                    }) : e.setData({
                        moneyList: a.concat(n),
                        page: e.data.page + 1,
                        hasMoreData: !0,
                        According: !1
                    });
                } else wx.showToast({
                    title: "暂无数据",
                    duration: 1e3
                });
            }
        });
    },
    onReady: function() {},
    onShow: function() {
        wx.showLoading(), this.getList();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.data.page = 1, console.log(this.data.page), this.getList();
    },
    onReachBottom: function() {
        this.data.hasMoreData ? this.getList() : wx.showToast({
            title: "没有更多数据",
            duration: 1e3,
            icon: "none"
        });
    },
    onShareAppMessage: function() {}
});